<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2017/4/29
 * Time: 22:46
 */

namespace app\controllers;


use app\components\WebAuthController;
use app\models\Comment;
use app\models\Like;

class CommentController extends WebAuthController {

    public $layout = 'detail';

    public function actionSave() {
        $model = new Comment();
        if (!$model->load($this->post())) {
            return $this->error('');
        }
        $model->status = Comment::STATUS_YES;
        $model->uid = $this->user->id;
        return $model->save();
    }

    public function actions() {
        return [
            'index' => [
                'class' => 'app\actions\CommentIndexAction',
                'title' => '评论列表',
                'modelClass' => Comment::className(),
            ],
            'like' => [
                'class' => 'app\actions\LikeAction',
                'modelClass' => Comment::className(),
                'own' => Like::OWN_COMMENT
            ],
        ];
    }
}